﻿// See https://aka.ms/new-console-template for more information

using System;
public class Program
{
    public static void Main(string[] args)
    {
        int[] a;
        string s;
        int n = 0;
        Console.Write("请输入数组长度:");
        s = Console.ReadLine();
        n = Int32.Parse(s);
        a = new int[n];
        Console.Write("请依次输入数组数据（每输入一个按一下回车）:\n");
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = Convert.ToInt32(Console.ReadLine());
        }
        int max = 0;
        
        for (int i = 0; i < a.Length; i++)
        {
            if (a[i] > max)
            {
                max = a[i];
            }
        }
        Console.WriteLine("最大值为 " + max);
        int min = max;
        for (int i = 0; i < a.Length; i++)
        {
            if (a[i] < min)
            {
                min = a[i];
            }
        }
        Console.WriteLine("最小值为 " + min);
        int sum = 0;
        for(int i = 0; i < a.Length; i++)
        {
            sum = sum + a[i];
        }
        double average = sum / n;
        Console.Write("平均数为 "+average);
        Console.Write("元素和为 " + sum);
    }
}
